import http from '@/plugins/axios'

export function getCustomerBenefitInquiry(data) {
  return http({
    method: 'POST',
    url: '/ykf/customer/shopBenefitPage',
    data
  }).then(res => {
    const l = []
    res.list.forEach((item, cIndex) => {
      const shopList = item.shopList || []
      if (!shopList.length) {
        l.push({ ...item, rowspan: 1 })
        return
      }
      shopList.forEach((chlid, index) => {
        const rowspan = index ? 0 : shopList.length
        const colspan = index ? 0 : 1
        l.push({ ...item, ...chlid, rowspan, colspan, _index: cIndex + 1 })
      })
    });
    return { ...res, list: l }
  })
}


export function getShopSubAccountInfo(data) {
  return http({
    method: 'POST',
    url: '/ykf/customer/shopBenefitDetail',
    data
  }).then(res => ({ list: res || [] }))
}
